<html>
<head>
<h1>Create New Account</h1>
</head>

<body>
<form action="addaccount.php" method="GET">
Account ID: 	 	<input type='text' name = 'ID' /> <br/>
Account Balance: 	<input type='text' name = 'Balance' /> <br/>
Account Balance limit: 	<input type='text' name = 'Bal_limit' /> <br/>
Account Status: 	<input type='text' name = 'Status' /> <br/>

<input type='submit' name = 'create' value='Create'/>
</form>
</body>
<?php
	require "configcmd.php";
	error_reporting(0);
	$Balance = $_GET['Balance'];
	$ID = $_GET['ID'];
	$Bal_limit = $_GET['Bal_limit'];
	$Status = $_GET['Status'];

	$con = mysql_connect("localhost",$db_user ,$db_pass);


	if (!$con){
		die('Could not connect: ' . mysql_error());
    }

	mysql_select_db($db_name, $con);
	
	if ($Bal_limit < $Balance){

	die('Balance cannot exceed credit limits!');

	}else{
	$sql_add = "INSERT INTO accounts (Bal_limit, Status,Balance,ID) VALUES ('$Bal_limit','$Status','$Balance', '$ID');";
	$result1 = mysql_query($sql_add);

	}

	mysql_close($con);


?>
<br />
<a href="main.php">Home</a>
</html>

